﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Xml.Serialization;
using Cleverscape.UTorrentClient.WebClient;

namespace uTorrentNetClient.ModelDesign
{
    public class Base : INotifyPropertyChanged
    {
        #region INotifyPropertyChanged

        /// <summary>
        /// Event to notify when a property of the torrent has changed
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        public void SetNotifyPropertyChanged(string PropertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
            }
        }

        #endregion


        private bool _hasChanges;
        [XmlIgnoreAttribute]
        public bool HasChanges
        {
            get { return _hasChanges; }
            private set
            {
                _hasChanges = value;
                SetNotifyPropertyChanged("HasChanges");
            }
        }

        public void ResetChanges()
        {
            HasChanges = false;
        }

        protected void setHasChanges(object oldValue, object newValue)
        {
            if (oldValue != newValue)
            {
                HasChanges = true;
            }
        }
    }
}
